<?php echo $this->fetch('header.html'); ?>
<?php echo $this->fetch('top.html'); ?>
<style>
    .coupon{}
    .coupon li{position: relative;text-align: left;width:288px;float:left;border: 1px solid #eee;margin:0 10px 10px 0;padding: 12px 15px;}
    .coupon li.last{margin-right:0px;}
    .coupon li p{height: 24px;line-height: 24px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 14px;text-align: center;}
    .coupon li .name{color: #666;font-weight:bold;}
    .coupon li .price{color:#f76120;font-size:15px;border-bottom: 1px #ddd dashed;padding-bottom:5px;}
    .coupon li .time{padding-top:5px;}
</style>
<script>
    function add_coupon(coupon_id){
        <?php if (! $this->_var['visitor']['user_id']): ?>
        alert(lang.login_please);
        return;
        <?php endif; ?>
        var url = SITE_URL + '/index.php?app=my_coupon&act=add';
            $.getJSON(url, {'coupon_id': coupon_id}, function (data) {
            if (data.done)
            {
                alert(data.retval);
            }
            else
            {
                alert(data.msg);
            }
        });
    }
</script>
<div id="content">
    <div id="left">
        <?php echo $this->fetch('left.html'); ?>
    </div>
    <div id="right">
        <ul class="coupon">
            <?php $_from = $this->_var['coupons']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'coupon');$this->_foreach['fe_coupon'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_coupon']['total'] > 0):
    foreach ($_from AS $this->_var['coupon']):
        $this->_foreach['fe_coupon']['iteration']++;
?>
            <li onclick="add_coupon(<?php echo $this->_var['coupon']['coupon_id']; ?>)" <?php if ($this->_foreach['fe_coupon']['iteration'] % 3 == 0): ?>class="last"<?php endif; ?>>
                <img  src="<?php echo htmlspecialchars($this->_var['coupon']['coupon_bg']); ?>" width="288" height="160">
                <p class="name" ><?php echo $this->_var['coupon']['coupon_name']; ?></p>
                <p class="price" >
                    <?php if ($this->_var['coupon']['coupon_value']): ?>满<?php echo price_format($this->_var['coupon']['min_amount']); ?>可抵扣<?php echo price_format($this->_var['coupon']['coupon_value']); ?><?php else: ?>no_limit<?php endif; ?>
                </p>
                <p class="time" ><?php echo local_date("Y-m-d",$this->_var['coupon']['start_time']); ?> 至 <?php if ($this->_var['coupon']['end_time']): ?><?php echo local_date("Y-m-d",$this->_var['coupon']['end_time']); ?><?php else: ?>no_limit<?php endif; ?></p>
            </li>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
        </ul>
    </div>
    <div class="clear"></div>
</div>
<?php echo $this->fetch('footer.html'); ?>